# 看涨

u <- 1.1
d <- 0.9
r <- 0.04
T <- 0.25

f_u <- 1
f_d <- 0

p <- (exp(r * T) - d) / (u - d)

f <- (exp(-r * T)) * (p * f_u + (1 - p) * f_d)

print(p)
print(f)


f_b <- (exp(-r*T)) * (p * 3.2 + (1 - p) * 0)
print(f_b)

f_a <- (exp(-r*T)) * (p * f_b + (1 - p) * 0)
print(f_a)


# 看跌

SK <- 52
u <- 1.2
d <- 0.8
T <- 1
r <- 0.05

p <- (exp(r * T) - d) / (u - d)
f_b <- (exp(-r * T)) * (p * 0 + (1 - p) * 4)
f_c <- (exp(-r * T)) * (p * 4 + (1 - p) * 20)
f_a <- (exp(-r * T)) * (p * f_b + (1 - p) * f_c)

# 美式期权
f_cc <- 12
f_ac <- (exp(-r * T)) * (p * f_b + (1 - p) * f_cc)
print(f_ac)
